package com.momo.seckilling.control;

import com.momo.seckilling.service.SeckillByService;
import com.momo.seckilling.service.SeckillIntegrationByService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by li on 2019/2/2.
 */
@RestController
@RequestMapping("seckKillByProductControl")
@Scope("prototype")
public class SeckKillByProductControl {

    @Autowired
    SeckillByService seckillByService;

    @Autowired
    SeckillIntegrationByService seckillIntegrationByService;

    @RequestMapping(value = "procedureLockBy",method = RequestMethod.GET)
    public Map<String,String> procedureLockBy(int userid,int id, Model model){
        Map<String,String> dataMap = seckillByService.procedureLockBy(userid,id);
        return dataMap;
    }

    @RequestMapping(value = "procedureLockByAOP",method = RequestMethod.GET)
    public Map<String,String> procedureLockByAOP(int userid,int id, Model model){
        Map<String,String> dataMap = seckillByService.procedureLockByAOP(userid,id);
        return dataMap;
    }

    @RequestMapping(value = "multiThread",method = RequestMethod.GET)
    public void multiThread(int userid,int id, Model model){
        seckillByService.multiThread(userid,id);
    }


    @RequestMapping(value = "pessimismLock",method = RequestMethod.GET)
    public Map<String,String> pessimismLock(int userid,int id, Model model){
        Map<String,String> dataMap = seckillByService.pessimismLock(userid,id);
        return dataMap;
    }

    @RequestMapping(value = "optimisticLock",method = RequestMethod.GET)
    public Map<String,String> optimisticLock(int userid,int id, Model model){
        Map<String,String> dataMap = seckillByService.optimisticLock(userid,id);
        return dataMap;
    }

    @RequestMapping(value = "queueAndThread",method = RequestMethod.GET)
    public void queueAndThread(int userid,int id, Model model){
        seckillByService.queueAndThread(userid,id);
    }

    @RequestMapping(value = "redisDistributeLock",method = RequestMethod.GET)
    public Map<String,String> redisDistributeLock(int userid, int id){
        return seckillByService.redisDistributeLock(userid,id);
    }

    @RequestMapping(value = "seckillFuture",method = RequestMethod.GET)
    public void seckillFuture(int userid, int id){
        seckillByService.seckillFuture(userid,id);
    }

    @RequestMapping(value = "seckillIntegrByDistrAndFuture",method = RequestMethod.GET)
    public void seckillIntegrByDistrAndFuture(int userid, int id){
        seckillIntegrationByService.seckillIntegrByDistrAndFuture(userid,id);
    }



    
}
